import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * @Description
 * @author Jerry
 * @date 2016-10-06
 */
public class ClassDemo1 {
    public static void main(String[] args) {
        String a ="123";
      //  ClassUtil.printMessage(a);
        ArrayList list = new ArrayList();
        ArrayList list1 = new ArrayList();
        list1.add("hello");

        Class c =list.getClass();
        Class c1 = list1.getClass();

        try {
           Method method = c1.getMethod("add",Object.class);
            method.invoke(list1,20);
            System.out.println(list1);
            for (int i = 0; i <list1.size() ; i++) {
                System.out.println(list1.get(i));
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

}
